<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

Route::group(['namespace' => 'Api'], function () {

    Route::post('login', 'LoginController@login')->name('api.login');
    Route::post('register', 'LoginController@register')->name('api.register');

    Route::post('product', 'ProductController@index')->name('api.product');

    Route::get('config', 'BindUserController@config')->name('admin.config');

    Route::get('level', 'LevelController@index')->name('api.level');

//    Route::any('notify', 'PayController@notify')->name('api.notify');
    Route::any('message', 'MessageController@index')->name('api.message');


    Route::group(['middleware' => 'CheckToken'], function () {

        Route::post('vpn', 'VpnController@index')->name('api.vpn');
        Route::get('userInfo', 'UserController@index')->name('api.user');
        Route::get('orders', 'UserController@orders')->name('api.orders');

        Route::post('verify', 'PayController@applePurchase')->name('api.pay');
        Route::post('recovery', 'PayController@recovery')->name('api.recovery');


        Route::post('bind', 'BindUserController@bindUser')->name('admin.bind');
        Route::post('opinion', 'OpinionController@save')->name('opinion.save');

        Route::post('change/password', 'UserController@changePassword')->name('user.save');
    });
});
